﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace CapstoneProjectAEReader.Entities.Models
{
    [Serializable()]
    public class Ebook : ISerializable
    {
        public int Id { get; set; }

        public string Author { get; set; }

        public string Title { get; set; }

        public string Path { get; set; }

        public string BookmarkPath { get; set; }

        public string Type { get; set; }

        public byte Rating { get; set; }

        public List<string> Group  =new List<string>();

        public string GroupInText { get; set; }

        public string Description { get; set; }

        public string ImportDate { get; set; }

        public int CurrentPage { get; set; }

        public int PageCount { get; set; }

        public string Publisher { get; set; }

        public Ebook(){}

        // Serialize
        public Ebook(SerializationInfo info, StreamingContext ctxt)
        {
            Id = (int)info.GetValue("Id", typeof(int));
            Author = (string)info.GetValue("Author", typeof(string));
            Title = (string)info.GetValue("Title", typeof(string));
            Path = (string)info.GetValue("Path", typeof(string));
            Type = (string) info.GetValue("Type", typeof (string));
            Rating = (byte)info.GetValue("Rating", typeof(byte));
            Group = (List<string>)info.GetValue("Group", typeof(List<string>));
            Description = (string)info.GetValue("Description", typeof(string));
            ImportDate = (string)info.GetValue("ImportDate", typeof(string));
            CurrentPage = (int)info.GetValue("CurrentPage", typeof(int));
            PageCount = (int) info.GetValue("PageCount", typeof (int));
            BookmarkPath = (string) info.GetValue("BookmarkPath", typeof (string));
            GroupInText = (string) info.GetValue("GroupInText", typeof (string));
            Publisher = (string) info.GetValue("Publisher", typeof (string));
        }

        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("Id", Id);
            info.AddValue("Author", Author);
            info.AddValue("Title", Title);
            info.AddValue("Path", Path);
            info.AddValue("Type",Type);
            info.AddValue("Rating", Rating);
            info.AddValue("Group", Group);
            info.AddValue("Description", Description);
            info.AddValue("ImportDate", ImportDate);
            info.AddValue("CurrentPage", CurrentPage);
            info.AddValue("PageCount",PageCount);
            info.AddValue("BookmarkPath",BookmarkPath);
            info.AddValue("GroupInText",GroupInText);
            info.AddValue("Publisher",Publisher);
        }
    }
}